package com.zm.zyz.mapper;

import com.zm.zyz.entity.ZyzTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zm.zyz.entity.ZyzUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zm
 * @since 2024-07-28
 */
public interface ZyzTaskMapper extends BaseMapper<ZyzTask> {
    @Select("select * from zyz_task where id = #{id}")
    @Results(id="rm1",
            value = {
                @Result(id = true,column = "id",property = "id"),
                @Result(column = "uid",property = "uid"),
                @Result(column = "uid",property = "user",
                    one = @One(select = "com.zm.zyz.mapper.ZyzUserMapper.selectById")
                ),
                @Result(column = "id",property = "joins",
                        many = @Many(select = "selectUserByTid")
                )
            }
    )
    ZyzTask findById(String id);

    @Select("select * from zyz_user join zyz_joins on zyz_user.id = zyz_joins.uid where zyz_joins.tid = #{tid}")
    List<ZyzUser> selectUserByTid(Integer tid);
}
